package com.mapreduce;

import com.bean.IdFlag;
import org.apache.hadoop.io.WritableComparable;
import org.apache.hadoop.io.WritableComparator;

public class IdGroup extends WritableComparator {
    public IdGroup(){
        super(IdFlag.class,true);
    }

    @Override
    public int compare(WritableComparable a, WritableComparable b) {
        IdFlag data1 = (IdFlag) a;
        IdFlag data2 = (IdFlag) b;
        // 返回0就会进入同一个分组下面,
        // 也就是编号相同的数据会进入同一个组
        return data1.getId().compareTo(data2.getId());
    }
}
